using MediatR;
using SumerCoreDevOps.Application.NodeLogs.Queries;
using SumerCoreDevOps.Domain.Entities;
using SumerCoreDevOps.Infrastructure.Logging;

namespace SumerCoreDevOps.Application.NodeLogs.Handlers;

public class GetLogsByNodeIdQueryHandler : IRequestHandler<GetLogsByNodeIdQuery, List<NodeOperationLog>>
{
    private readonly NodeOperationLogManager _logManager;

    public GetLogsByNodeIdQueryHandler(NodeOperationLogManager logManager)
    {
        _logManager = logManager;
    }

    public async Task<List<NodeOperationLog>> Handle(GetLogsByNodeIdQuery request, CancellationToken cancellationToken)
    {
        return await _logManager.GetLogsByNodeIdAsync(request.NodeId, request.Limit, request.Offset);
    }
}
